<?php

/*
// @author : lael
// blog : http://hi.baidu.com/lael80
// http://www.gzyd.net
// all right reserved.
*/

namespace ydsdk\controllers\admin;

class date extends \ydsdk\core\admin {
	public function __construct(){
		parent::__construct();
		if($_SESSION['admin']['type'] != 1)show_message('没有访问权限', siteurl('con=admin/index'));
	}

	public function index(){
		$time=strtotime(date('Y-m-d H:i:s'));
		$c=date('N', $time);
		// $list = $this->db->get_arr('date');
		$list = $this->db->get_arr('date');
		foreach($list as $k=>$v){
			$d=$v['da_start'];
			$list=explode(',',$d);

		}
		var_dump($list);exit;
		$this->smarty->assign('list', $list);
		$this->smarty->display('date/index.html');
	}

	public function edit(){
		if(issubmit()){
			$data = $this->formdata('date');
			if($_GET['id']){
				$this->db->update('date', $data, "da_id=".$_GET['id']);
			}else{
				$this->db->insert('date', $data);
			}
			exitjson(1);
		}
		if($_GET['id']){
			$row = $this->db->get_row('date', '*', array('da_id' => $_GET['id']));
			if(!$row)show_message('数据不存在');
			$this->smarty->assign('row', $row);	
		}
		$this->smarty->display('date/edit.html');	
	}
	
	public function delete(){
		if(!empty($_POST['ids'])){
			$this->db->delete('date', 'da_id in ('.$_POST['ids'].')');	
		}
		exitjson(1);	
	}
}
